from fastapi import Depends, FastAPI
from fastapi.middleware.cors import CORSMiddleware
from tortoise.contrib.fastapi import register_tortoise

from core.config import settings, TORTOISE_ORM
from dependencies import get_current_admin_user
from routers import application, users, internal, chat_application


if settings.ENV == "pro":
    app = FastAPI(docs_url=None, redoc_url=None)
else:
    app = FastAPI()


app.include_router(users.router)
app.include_router(application.router)
app.include_router(chat_application.router)

# internal
app.include_router(internal.internal_router)


app.add_middleware(
    CORSMiddleware,
    allow_origins=settings.ORIGINS,
    allow_credentials=True,
    allow_methods=["*"],
    allow_headers=["*"],
)

register_tortoise(
    app,
    config=TORTOISE_ORM,
    # generate_schemas=True,
    add_exception_handlers=True,
)


@app.get("/")
async def root():
    return {"message": "Hello Bigger Applications!"}


if __name__ == '__main__':
    import uvicorn
    uvicorn.run(app='main:app', host="0.0.0.0", port=8000, reload=True, proxy_headers=True, forwarded_allow_ips="*")